//
// DepRepoComponent
//
// Copyright (C) jextra.net.
//
//  This file is part of the net.jextra.dep Library.
//
//  The net.jextra.dep Library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Lesser General Public
//  License as published by the Free Software Foundation; either
//  version 2.1 of the License, or (at your option) any later version.
//
//  The net.jextra.dep Library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with the net.jextra.dep Library; if not, write to the Free
//  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
//  02111-1307 USA.
//

package net.jextra.dep.repo;

/**
 * <p>
 * A component within a repository.
 * </p>
 */
public class DepRepoComponent implements Comparable<DepRepoComponent>
{
    // ============================================================
    // Fields
    // ============================================================

    private String componentName;
    private long timestamp;

    // ============================================================
    // Constructors
    // ============================================================

    public DepRepoComponent( String componentName )
    {
        this( componentName, 0L );
    }

    public DepRepoComponent( String componentName, long timestamp )
    {
        assert componentName != null : "Component must have a name";

        this.componentName = componentName;
        this.timestamp = timestamp;
    }

    // ============================================================
    // Methods
    // ============================================================

    // ----------
    // public
    // ----------

    public String getComponentName()
    {
        return componentName;
    }

    public void getName( String componentName )
    {
        this.componentName = componentName;
    }

    public long getTimestamp()
    {
        return timestamp;
    }

    public void setTimestamp( long timestamp )
    {
        this.timestamp = timestamp;
    }

    @Override
    public boolean equals( Object obj )
    {
        if ( !( obj instanceof DepRepoComponent ) )
        {
            return false;
        }

        DepRepoComponent other = (DepRepoComponent)obj;

        if ( !componentName.equals( other.componentName ) )
        {
            return false;
        }

        return true;
    }

    @Override
    public int compareTo( DepRepoComponent other )
    {
        return componentName.compareTo( other.componentName );
    }
}

